<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * HITI AdminCP
 *
 * @package     HITI AdminCP Project
 * @since       Monday, October 21, 2013, 6:00 PM
 * @final
 * @category    Models
 * @see 		Hiti
 * @author      PHUOCNGUYEN - HITI Dev Team
 * @copyright   Copyright (c) 2013, HITI Corp
 */

class Hiti_model extends CI_Model {
	public function __contruct()
	{
		parent::__contruct();
	}

	public function load_config()
	{
		$keyword = array(
			'site_url',
			'smtp_host',
			'smtp_ssl',
			'smtp_port',
			'smtp_user',
			'smtp_pass',
			'smtp_mailer',
			'contact_email',
			'develop_mode',
			'multi_lang',
			'body_skin',
			'news_image_width',
			'news_image_height',
			'news_thumb_width',
			'news_thumb_height',
			'news_gallery_width',
			'news_gallery_height',
			'prod_image_width',
			'prod_image_height',
			'prod_thumb_width',
			'prod_thumb_height',
			'prod_gallery_width',
			'prod_gallery_height',
			'proj_image_width',
			'proj_image_height',
			'proj_thumb_width',
			'proj_thumb_height',
			'proj_gallery_width',
			'proj_gallery_height',
			'video_image_width',
			'video_image_height',
			'video_thumb_width',
			'video_thumb_height',
			'video_gallery_width',
			'video_gallery_height',
			'serv_image_width',
			'serv_image_height',
			'serv_thumb_width',
			'serv_thumb_height',
			'serv_gallery_width',
			'serv_gallery_height',
			'show_cpanel',
			'company_name_vn',
			'company_name_en',
			'address_vn',
			'address_en',
			'tel',
			'site_url',
			'account1_name',
			'account2_name',
			'account1_number',
			'account2_number',
			'bank1_part',
			'bank2_part',
			'bank1_name',
			'bank2_name'
		);
		$this->db->query('SET NAMES "LATIN1"');
		$this->db->select('keyword, value');
		$this->db->where_in('keyword', $keyword);
		$query = $this->db->get('config');
		foreach ($query->result() as $val) {
			$GLOBALS['cfg'][$val->keyword] = $val->value;
		}
		$GLOBALS['var']['body_skin'] = $this->input->cookie('body_skin', true);
		if (!$GLOBALS['var']['body_skin'])
		{
			$GLOBALS['var']['body_skin'] = $GLOBALS['cfg']['body_skin'];
		}
		$GLOBALS['var']['sidebar_collapsed'] = $this->input->cookie('sidebar_collapsed', true);
		if (!$GLOBALS['var']['sidebar_collapsed'])
		{
			$GLOBALS['var']['sidebar_collapsed'] = 0;
		}
		$GLOBALS['var']['act'] = $this->uri->segment(1);
		$GLOBALS['var']['do'] = $this->uri->segment(2);
		$GLOBALS['var']['id'] = $this->uri->segment(3);
		if (!$GLOBALS['var']['id'])
		{
			$GLOBALS['var']['id'] = $this->input->get('id', true);
		}
		$GLOBALS['var']['deleted'] = $this->input->get('deleted', true) ? 1 : 0;
		$GLOBALS['var']['rowstart'] = $this->input->get('rowstart', true);
		if (!$GLOBALS['var']['rowstart'])
		{
			$GLOBALS['var']['rowstart'] = 0;
		}
		$GLOBALS['var']['token'] = $this->session->userdata('token', true);
		$GLOBALS['var']['logged_in'] = $this->session->userdata('logged_in', true);
		$GLOBALS['var']['user_id'] = $this->session->userdata('user_id', true);
		if ($GLOBALS['var']['user_id'] > 0)
		{
			$this->db->select('id, username, user_rights, level, last_login, icon, fullname, viewall, coso, email, mode_right');
			$this->db->where('id', $GLOBALS['var']['user_id']);
			$GLOBALS['user'] = $this->db->get('users')->row_array();
			if ($GLOBALS['user']['mode_right'])
			{
				$group_rights = get_data('usergroups', 'id = "'.$GLOBALS['user']['level'].'"', 'group_rights');
				$GLOBALS['var']['user_rights'] = $group_rights;
				$GLOBALS['user']['user_rights'] = $group_rights;
			}
			else
			{
				$GLOBALS['var']['user_rights'] = $GLOBALS['user']['user_rights'];
			}
		}
		$GLOBALS['var']['mytab'] = $this->input->cookie('mytab-'.$GLOBALS['var']['act'].'-'.$GLOBALS['var']['do'], true);
		$GLOBALS['var']['mytab'] = $GLOBALS['var']['mytab'] ? $GLOBALS['var']['mytab'] : 0;
		$GLOBALS['var']['filter_cat'] = $this->input->cookie('filter_cat', true);
		$GLOBALS['per']['edit'] = check_rights('', 'edit');
		$GLOBALS['per']['add'] = check_rights('', 'add');
		$GLOBALS['per']['del'] = check_rights('', 'del');
	}
}

/* End of file hiti_model.php */
/* Location: ./application/models/hiti_model.php */